//author:kakake
//1.预约挂号支付，调起收银台支付，支付成功后会回调通知tspaynotifyController
//2.预约挂号退费，调起退费接口，退款成功后会回调通知tspaynotifyController
//3.自助缴费支付，调起收银台支付，支付成功后会回调通知tspaynotifyController

//author:kakake
var Common = /** @class */ (function () {
    function Common() {
    }
    return Common;
}());

//author:kakake
var tspaynotifyService = /** @class */ (function () {
    function tspaynotifyService(workid) {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn(),
            WorkId: 1
        };
        this.data.WorkId = workid;
    }
    return tspaynotifyService;
}());

//author:kakake
/**
 * 以下两个接口以应用发布服务的方式提供给支付系统应用调用
 */
var tspaynotifyController = /** @class */ (function () {
    function tspaynotifyController() {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn(),
            WorkId: 1
        };
        this.data.WorkId = TSLobsterAPI.Program.GetWorkId();
        this.service = new tspaynotifyService(this.data.WorkId);
        this.dao = new tspaynotifyDao(this.data.WorkId);
        this.tsregisterservice = new tsregisterService(this.data.WorkId);
        this.tsselfpayservice = new tsselfpayService(this.data.WorkId);
    }
    /**
     * 支付成功回调此函数
     * 参数：
        let body = JSON.parse(TSLobsterAPI.Program.RequestBody());
        let backpayobj = {
            OrderType: body.OrderType,                  //1挂号支付 2处方支付
            OrderNo: body.OrderNo || '',                //支付系统生成的订单号
            TransactionId: body.TransactionId || '',    //微信支付生成的唯一号
            BusinessOrderNo: body.BusinessOrderNo || 0, //业务号，对应WPMT_RegisteredPayment和WPMT_PresPayment表的主键
            SubMchId: body.SubMchId,                    //商户号
            PayType: body.payType,                      //支付方式 1微信 2医保 3其它
            PayDate: body.PayDate,                      //支付时间
            PayFee: parseFloat(body.PayFee) / 100       //支付金额 到分
        }
     */
    tspaynotifyController.prototype.paysuccess = function () {
        var model = JSON.parse(TSLobsterAPI.Program.RequestBody());
        if (model.OrderType == 1) {
            //挂号费支付成功
            this.tsregisterservice.registerpaysuccess(model);
        }
        else if (model.OrderType == 2) {
            //处方支付成功
            this.tsselfpayservice.balancepaysuccess(model);
        }
        return { result: true };
    };
    /**
     * 退款成功回调此函数
        let body = JSON.parse(TSLobsterAPI.Program.RequestBody());
        let backrefundobj = {
            OrderType: body.OrderType,                              //1挂号支付 2处方支付
            OrderNo: body.OrderNo || '',                            //支付系统生成的订单号
            TransactionId: body.TransactionId || '',                //微信支付生成的唯一号
            BusinessOrderNo: body.BusinessOrderNo || 0,             //业务号，对应WPMT_RegisteredPayment和WPMT_PresPayment表的主键
            RefundNo:body.RefundNo || '',                           //退款订单号
            RefundTransactionId:body.RefundTransactionId || '',     //退款交易流水号
            SubMchId: body.SubMchId,                                //商户号
            PayType: body.payType,                                  //支付方式 1微信 2医保 3其它
            RefundDate: body.RefundDate,                            //支付时间
            RefundFee: parseFloat(body.RefundFee) / 100             //支付金额 到分
        }
     */
    tspaynotifyController.prototype.refundsuccess = function () {
        var model = JSON.parse(TSLobsterAPI.Program.RequestBody());
        if (model.OrderType == 1) {
            //退挂号费成功
            this.tsregisterservice.cancelregisterrefundsuccess(model);
        }
        else if (model.OrderType == 2) {
            //处方退费成功
        }
        return { result: true };
    };
    return tspaynotifyController;
}());

//author:kakake
var tspaynotifyDao = /** @class */ (function () {
    function tspaynotifyDao(workid) {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn(),
            WorkId: 1
        };
        this.data.WorkId = workid;
    }
    return tspaynotifyDao;
}());

